/** init domain config */
import './config'

import Vue from 'vue'
import App from './App.vue'
import Storage from 'vue-ls'
import router from './router'
import store from './store/'
import { VueAxios } from "@/utils/request"
import { Button, Upload, Loading, Dialog, Table, TableColumn } from 'element-ui';

require('@jeecg/antd-online-mini')
require('@jeecg/antd-online-mini/dist/OnlineForm.css')

import Antd, { version } from 'ant-design-vue'
console.log('ant-design-vue version:', version)

import Viser from 'viser-vue'
import 'ant-design-vue/dist/antd.less'; // or 'ant-design-vue/dist/antd.less'

import '@/permission' // permission control
import '@/utils/filter' // base filter
// import Print from 'vue-printjs'
import Print from 'vue-print-nb-jeecg'
Vue.use(Print)
import SSO from '@/cas/sso.js'
import Printer from './utils/print.js'
Vue.use(Printer)
import UserInputSelector from '@/selector/UserInputSelector'
import CodeSelector from '@/selector/CodeSelector'
Vue.component("UserInputSelector",UserInputSelector)
Vue.component("CodeSelector",CodeSelector)
import htmlToPdf from '@/utils/htmlToPdf'
Vue.use(htmlToPdf)
import {
    ACCESS_TOKEN,
    DEFAULT_COLOR,
    DEFAULT_THEME,
    DEFAULT_LAYOUT_MODE,
    DEFAULT_COLOR_WEAK,
    SIDEBAR_TYPE,
    DEFAULT_FIXED_HEADER,
    DEFAULT_FIXED_HEADER_HIDDEN,
    DEFAULT_FIXED_SIDEMENU,
    DEFAULT_CONTENT_WIDTH_TYPE,
    DEFAULT_MULTI_PAGE
} from "@/store/mutation-types"
import config from '@/defaultSettings'

import JDictSelectTag from './components/dict/index.js'
import hasPermission from '@/utils/hasPermission'
import vueBus from '@/utils/vueBus';
import JeecgComponents from '@/components/jeecg/index'
import '@/assets/less/JAreaLinkage.less'
import '@/components/svgIcon/index.js'
//表单验证
import { rules } from '@/utils/rules'

import { windowOpen } from '@/utils/windowOpen'
import infiniteScroll from 'vue-infinite-scroll'
import { TransferSelector, FoldFiltrate, OrganizationTree } from 'haday-design-admin'
Vue.prototype.rules = rules
Vue.prototype.windowOpen = windowOpen
Vue.config.productionTip = false
Vue.use(Storage, config.storageOptions)
Vue.use(Antd)
Vue.use(VueAxios, router)
Vue.use(Viser)

Vue.use(hasPermission)
Vue.use(JDictSelectTag)
Vue.use(Print)
Vue.use(vueBus);
Vue.use(JeecgComponents);

Vue.use(Button)
Vue.use(Upload)
Vue.use(Dialog)
Vue.use(Loading)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(infiniteScroll)
Vue.use(TransferSelector);
Vue.use(FoldFiltrate);
Vue.use(OrganizationTree);
import { message} from 'ant-design-vue'
Vue.prototype.$messageWorkReport = message;
message.config({
    duration: 2,// 持续时间
    top:`150px`, // 到页面顶部距离
    maxCount: 3 // 最大显示数, 超过限制时，最早的消息会被自动关闭
})
SSO.init(() => {
    main()
})

function main() {
    new Vue({
        router,
        store,
        mounted() {
            store.commit('SET_SIDEBAR_TYPE', Vue.ls.get(SIDEBAR_TYPE, true))
            store.commit('TOGGLE_THEME', Vue.ls.get(DEFAULT_THEME, config.navTheme))
            store.commit('TOGGLE_LAYOUT_MODE', Vue.ls.get(DEFAULT_LAYOUT_MODE, config.layout))
            store.commit('TOGGLE_FIXED_HEADER', Vue.ls.get(DEFAULT_FIXED_HEADER, config.fixedHeader))
            store.commit('TOGGLE_FIXED_SIDERBAR', Vue.ls.get(DEFAULT_FIXED_SIDEMENU, config.fixSiderbar))
            store.commit('TOGGLE_CONTENT_WIDTH', Vue.ls.get(DEFAULT_CONTENT_WIDTH_TYPE, config.contentWidth))
            store.commit('TOGGLE_FIXED_HEADER_HIDDEN', Vue.ls.get(DEFAULT_FIXED_HEADER_HIDDEN, config.autoHideHeader))
            store.commit('TOGGLE_WEAK', Vue.ls.get(DEFAULT_COLOR_WEAK, config.colorWeak))
            store.commit('TOGGLE_COLOR', Vue.ls.get(DEFAULT_COLOR, config.primaryColor))
            store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN))
            store.commit('SET_MULTI_PAGE', Vue.ls.get(DEFAULT_MULTI_PAGE, config.multipage))
        },
        render: h => h(App)
    }).$mount('#app')
}

Vue.directive("title", {
    inserted: function(el, binding) {
        document.title = el.dataset.title;
    }
});